from classroom import Classroom
from teacher import Teacher


from info_collect import db
from datetime import datetime


def obj_to_dict(obj):
    def get_key_value(col):
        if isinstance(getattr(obj, col), datetime):
            return col, getattr(obj, col).isoformat()
        else:
            return col, getattr(obj, col)
    columns = [column.key for column in db.class_mapper(obj.__class__).columns]
    return dict(map(get_key_value, columns))
